/**
 * 
 */
package com.java.test.paymanage.mapper;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Component;

import com.java.test.paymanage.dto.RechargeDiscountInfo;

/**
 * @author Administrator
 *
 */
@Component
public class RechargeDiscountMapper {

	@Autowired
	private JdbcTemplate jdbcTemplate;


	public List<RechargeDiscountInfo> selectrechargediscountList() {
		String sql = "select * from paymanage_rechargediscount";

		List<RechargeDiscountInfo> list = jdbcTemplate.query(sql, new RechargeDiscountInfo());

		return list;
	}

	public int insertrechargediscountInfo(RechargeDiscountInfo info) {

		String sql = "insert into paymanage_rechargediscount"
				+ "(discount_name,discount_range,multiple,amount,received_amount)values(?,?,?,?,?)";

		int i = jdbcTemplate.update(sql, info.getDiscountName(), info.getDiscountRange(), info.getMultiple(),
				info.getAmount(), info.getReceivedAmount());

		return i;

	}

	public int deleterechargediscountInfo(RechargeDiscountInfo info) {

		String sql = "delete from paymanage_rechargediscount where id=?";

		int i = jdbcTemplate.update(sql, info.getId());

		return i;

	}

	public int updaterechargediscountInfo(RechargeDiscountInfo info) {

		String sql = "update paymanage_rechargediscount set discount_name=?,discount_range=?,"
				+ "multiple=?,amount=?,received_amount=? where id=?";

		int i = jdbcTemplate.update(sql, info.getDiscountName(), info.getDiscountRange(), info.getMultiple(),
				info.getAmount(), info.getReceivedAmount(), info.getId());

		return i;

	}

	
	
}
